package com.delivery.www.service.ServiceImpl;

import com.delivery.www.dao.UserDao;
import com.delivery.www.dao.DaoImpl.UserDaoImpl;
import com.delivery.www.po.User;
import com.delivery.www.service.UserService;
import com.delivery.www.util.JdbcUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class UserServiceImpl implements UserService {
    private UserDao userDao;

    public UserServiceImpl() {
        userDao = new UserDaoImpl();
    }

    @Override
    public User login(String name, String password) {
        User user = null;
        user = userDao.login(name, password);
        return user;
    }

    @Override
    public boolean register(String name, String password, String email) {
        boolean flag = false;
        int i = userDao.register(name, password, 0.0F, email);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public boolean recharge(int userId, Float value) {
        boolean flag = false;
        int recharge = userDao.recharge(userId, value);
        if (recharge > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public List<User> getUser() {
        List<User> users = null;
        users = userDao.getUser();
        return users;
    }
}
